<template>
  <div class="app-container order-form-page">
    <!-- 添加或修改订单管理 -->
    <div class="order-form__header">
      <div class="order-form__title">{{ form.id ? '编辑订单' : '新建订单' }}</div>
      <div class="order-form__actions">
        <el-button size="mini" @click="cancel">关 闭</el-button>
        <el-button v-if="!form.status || form.status === 1" v-hasPermi="['order:order:add']" size="mini" type="primary"
                   @click="submitForm">保 存
        </el-button>
        <el-button v-if="!form.status || form.status === 1" v-hasPermi="['order:order:add']" size="mini" type="primary"
                   @click="submitFormAndPrint">保存并打印
        </el-button>
        <el-button v-if="form.status === 1 && form.recheckStatus === 'Y'" v-hasPermi="['order:order:confirm']"
                   size="mini" type="info" @click="confirmSingleOrder">确认订单
        </el-button>
        <el-button v-if="form.id" size="mini" icon="el-icon-printer" v-hasPermi="['order:order:print']" type="warning"
                   @click="printSingleOrder">打印订单
        </el-button>
        <el-button v-if="form.status === 1 && form.recheckStatus === 'N'" size="mini"
                   v-hasPermi="['order:order:recheck']" type="danger" @click="openRecheck">复核订单
        </el-button>
      </div>
    </div>
    <el-form ref="form" :model="form" :rules="rules" label-width="100px">
      <el-divider content-position="left"><span class="divider-text">运输订单</span></el-divider>
      <el-row :gutter="20">
        <el-col :span="6">
          <el-form-item label="订单号" prop="backNumber">
            <el-input v-model="form.code" placeholder="系统自动生成" disabled/>
          </el-form-item>
        </el-col>
        <el-col :span="6">
          <el-form-item label="发货单号" prop="relateBill1">
            <el-input v-model="form.relateBill1" placeholder="请输入发货单号"/>
          </el-form-item>
        </el-col>
        <el-col :span="6">
          <el-form-item label="客户单号" prop="relateBill2">
            <el-input v-model="form.relateBill2" placeholder="请输入客户单号"/>
          </el-form-item>
        </el-col>
        <el-col :span="6">
          <el-form-item label="开单日期" prop="time">
            <el-date-picker clearable v-model="form.time" type="date" value-format="yyyy-MM-dd"
                            placeholder="请选择开单日期">
            </el-date-picker>
          </el-form-item>
        </el-col>
        <el-col :span="6">
          <el-form-item label="客户类型" prop="customerType">
            <el-radio-group v-model="form.customerType">
              <el-radio v-for="dict in dict.type.CustomerType" :key="dict.value" :label="parseInt(dict.value)">
                {{ dict.label }}
              </el-radio>
            </el-radio-group>
          </el-form-item>
        </el-col>
        <el-col :span="6">
          <el-form-item label="客户名称" prop="customerName">
            <!--              <el-autocomplete v-model="form.customerName" :fetch-suggestions="queryCustomerSearch"-->
            <!--                               placeholder="请输入客户名称进行搜索"-->
            <!--                               @select="handleCustomer"></el-autocomplete>-->

            <el-select v-if="!form.id" v-model="form.jcCustomerId" filterable clearable remote reserve-keyword
                       placeholder="请输入客户名称进行搜索" :remote-method="remoteCustomerSearch"
                       @change="handleCustomer">
              <el-option v-for="item in customerList" :key="item.id" :label="item.name" :value="item.id"/>
            </el-select>
            <el-input v-else v-model="form.customerName" placeholder="请输入客户名称" readonly="readonly"/>
          </el-form-item>
        </el-col>
        <el-col :span="6">
          <el-form-item label="交付方式" prop="handoverType">
            <el-select clearable filterable v-model="form.handoverType" placeholder="请选择交付方式">
              <el-option v-for="dict in dict.type.HandoverType" :key="dict.value" :label="dict.label"
                         :value="parseInt(dict.value)"/>
            </el-select>
          </el-form-item>
        </el-col>
        <el-col :span="6">
          <el-form-item label="入库区域" prop="jcZoneStoreroomId">
            <el-select clearable filterable v-model="form.jcZoneStoreroomId" placeholder="请选择入库区域">
              <el-option v-for="dict in zoneStoreroomList" :key="dict.id" :label="dict.name"
                         :value="dict.id"/>
            </el-select>
          </el-form-item>
        </el-col>
        <el-col :span="12">
          <el-form-item label="出发运点" prop="jcStartZoneId">
            <el-select clearable filterable v-model="form.jcStartZoneId" placeholder="请选择出发运点"
                       style="width: 100%;">
              <el-option v-for="dict in startZoneList" :key="dict.id"
                         :label="dict.jcOrganizationIdDtLabel + '-' + dict.name" :value="dict.id"/>
            </el-select>
          </el-form-item>
        </el-col>
        <el-col :span="6">
          <el-form-item label="结算方式" prop="feeType">
            <el-select filterable v-model="form.feeType" placeholder="请选择结算方式">
              <el-option v-for="dict in dict.type.Clearing" :key="dict.value" :label="dict.label"
                         :value="parseInt(dict.value)"/>
            </el-select>
          </el-form-item>
        </el-col>
        <el-col :span="6">
          <el-form-item label="销售负责人" prop="salePerson">
            <el-input v-model="form.salePerson" placeholder="请输入销售负责人"/>
          </el-form-item>
        </el-col>
        <el-col :span="6">
          <el-form-item label="目的站" prop="jcToOrganizationId">
            <el-select filterable v-model="form.jcToOrganizationId" placeholder="请选择目的站" @change="changeToOrg">
              <el-option v-for="dict in targetOrgList" :key="dict.id" :label="dict.name"
                         :value="dict.id"/>
            </el-select>
          </el-form-item>
        </el-col>
        <el-col :span="12">
          <el-form-item label="目的运点" prop="jcEndZoneId">
            <el-select filterable v-model="form.jcEndZoneId" placeholder="请选择目的运点" style="width: 100%;"
                       @change="changeEndZone">
              <el-option v-for="dict in endZoneList" :key="dict.id"
                         :label="dict.jcOrganizationIdDtLabel + '-' + dict.name"
                         :value="dict.id"/>
            </el-select>
          </el-form-item>
        </el-col>
        <el-col :span="6">
          <el-form-item label="运输性质" prop="transportPro">
            <el-select filterable v-model="form.transportPro" placeholder="请选择运输性质">
              <el-option v-for="dict in dict.type.TransportPro" :key="dict.value" :label="dict.label"
                         :value="parseInt(dict.value)"/>
            </el-select>
          </el-form-item>
        </el-col>
        <el-col :span="6">
          <el-form-item label="要求发运时间" prop="planLeaveTime">
            <el-date-picker clearable v-model="form.planLeaveTime" type="date" value-format="yyyy-MM-dd"
                            placeholder="请选择要求发运时间">
            </el-date-picker>
          </el-form-item>
        </el-col>
        <el-col :span="6">
          <el-form-item label="要求到达时间" prop="planArriveTime">
            <el-date-picker clearable v-model="form.planArriveTime" type="date" value-format="yyyy-MM-dd"
                            placeholder="请选择要求到达时间">
            </el-date-picker>
          </el-form-item>
        </el-col>
        <el-col :span="6">
          <el-form-item label="实际发运时间" prop="factLeaveTime">
            <el-date-picker clearable v-model="form.factLeaveTime" type="date" value-format="yyyy-MM-dd"
                            placeholder="请选择实际发运时间" disabled>
            </el-date-picker>
          </el-form-item>
        </el-col>
        <el-col :span="6">
          <el-form-item label="实际运抵日期" prop="factArriveTime">
            <el-date-picker clearable v-model="form.factArriveTime" type="date" value-format="yyyy-MM-dd"
                            placeholder="请选择实际运抵日期" disabled>
            </el-date-picker>
          </el-form-item>
        </el-col>
        <el-col :span="6">
          <el-form-item label="是否回单" prop="isBack">
            <el-radio-group v-model="form.isBack">
              <el-radio v-for="dict in dict.type.CommIsNot" :key="dict.value" :label="parseInt(dict.value)">
                {{ dict.label }}
              </el-radio>
            </el-radio-group>
          </el-form-item>
        </el-col>
        <el-col :span="6">
          <el-form-item label="回单份数" prop="backNumber" v-if="form.isBack === 1">
            <el-input v-model="form.backNumber" placeholder="请输入回单份数"/>
          </el-form-item>
        </el-col>
        <el-col :span="12">
          <el-form-item label="备注" prop="description">
            <el-input v-model="form.description" placeholder="请输入内容"/>
          </el-form-item>
        </el-col>
      </el-row>

      <el-divider content-position="left"><span class="divider-text">发货单位</span></el-divider>
      <el-row :gutter="20">
        <el-col :span="8">
          <el-form-item label="发货单位" prop="sender.name">
            <el-select filterable v-model="form.sender.name" placeholder="请选择发货单位"
                       @blur="blurSenderCustomerAddress" allow-create>
              <el-option v-for="addr in senderAddressList" :key="addr.id" :label="addr.name + '-' + addr.address"
                         :value="addr.name" @click.native="changeCustomerAddress(addr, 'sender')"/>
            </el-select>
          </el-form-item>
        </el-col>
        <el-col :span="5">
          <el-form-item label="发货人" prop="sender.contactperson">
            <el-input v-model="form.sender.contactperson" placeholder="请输入发货人"/>
          </el-form-item>
        </el-col>
        <el-col :span="6">
          <el-form-item label="地址类型" prop="sender.addressType">
            <el-radio-group v-model="form.sender.addressType">
              <el-radio v-for="dict in dict.type.AddressType" :key="dict.value" :label="dict.value">
                {{ dict.label }}
              </el-radio>
            </el-radio-group>
          </el-form-item>
        </el-col>
        <el-col :span="5">
          <el-form-item label="电话" prop="sender.iphone">
            <el-input v-model="form.sender.iphone" placeholder="请输入电话"/>
          </el-form-item>
        </el-col>
        <el-col :span="8">
          <el-form-item label="地址" prop="sender.address">
            <el-input v-model="form.sender.address" placeholder="请输入地址">
              <el-button slot="append" icon="el-icon-search" @click.native="selectPosition('sender')"></el-button>
            </el-input>
          </el-form-item>
        </el-col>
        <el-col :span="5">
          <el-form-item label="经纬度" prop="sender.ltl">
            <el-input v-model="form.sender.ltl" placeholder="请输入经纬度"/>
          </el-form-item>
        </el-col>
        <el-col :span="11">
          <el-form-item label="详细地址" prop="sender.detaileAddress">
            <el-input v-model="form.sender.detaileAddress" placeholder="请输入详细地址"/>
          </el-form-item>
        </el-col>
      </el-row>
      <el-divider content-position="left"><span class="divider-text">收货单位</span></el-divider>
      <el-row :gutter="20">
        <el-col :span="8">
          <el-form-item label="收货单位" prop="receiver.name">
            <el-select filterable v-model="form.receiver.name" placeholder="请选择收货单位"
                       @blur="blurReceiverCustomerAddress" allow-create>
              <el-option v-for="addr in senderAddressList" :key="addr.id" :label="addr.name + '-' + addr.address"
                         :value="addr.name" @click.native="changeCustomerAddress(addr, 'receiver')"/>
            </el-select>
          </el-form-item>
        </el-col>
        <el-col :span="5">
          <el-form-item label="收货人" prop="receiver.contactperson">
            <el-input v-model="form.receiver.contactperson" placeholder="请输入收货人"/>
          </el-form-item>
        </el-col>
        <el-col :span="6">
          <el-form-item label="地址类型" prop="receiver.addressType">
            <el-radio-group v-model="form.receiver.addressType">
              <el-radio v-for="dict in dict.type.AddressType" :key="dict.value" :label="dict.value">{{
                  dict.label
                }}
              </el-radio>
            </el-radio-group>
          </el-form-item>
        </el-col>
        <el-col :span="5">
          <el-form-item label="电话" prop="receiver.iphone">
            <el-input v-model="form.receiver.iphone" placeholder="请输入电话"/>
          </el-form-item>
        </el-col>
        <el-col :span="8">
          <el-form-item label="地址" prop="receiver.address">
            <el-input v-model="form.receiver.address" placeholder="请输入地址">
              <el-button slot="append" icon="el-icon-search" @click.native="selectPosition('receiver')"></el-button>
            </el-input>
          </el-form-item>
        </el-col>
        <el-col :span="5">
          <el-form-item label="经纬度" prop="receiver.ltl">
            <el-input v-model="form.receiver.ltl" placeholder="请输入经纬度"/>
          </el-form-item>
        </el-col>
        <el-col :span="11">
          <el-form-item label="详细地址" prop="receiver.detaileAddress">
            <el-input v-model="form.receiver.detaileAddress" placeholder="请输入详细地址"/>
          </el-form-item>
        </el-col>
      </el-row>
      <el-divider content-position="left"><span class="divider-text">订单货品明细信息</span></el-divider>
      <el-row :gutter="20">
        <el-row :gutter="10" class="mb8">
          <el-col :span="1.5">
            <el-button type="primary" icon="el-icon-plus" size="mini" @click="handleAddJcOrderProduct">添加
            </el-button>
          </el-col>
          <el-col :span="3">
            <el-button type="danger" icon="el-icon-delete" size="mini" @click="handleDeleteJcOrderProduct">删除
            </el-button>
          </el-col>
          <el-col :span="1.5">
            <el-button type="danger" icon="el-icon-plus" size="mini" @click="handleAddYP">添加无包装药品
            </el-button>
          </el-col>
        </el-row>
        <el-table :data="jcOrderProductList" :row-class-name="rowJcOrderProductIndex"
                  @selection-change="handleJcOrderProductSelectionChange" ref="jcOrderProduct" show-summary
                  :summary-method="getProductSummaries">
          <el-table-column type="selection" width="60" align="center"/>
          <el-table-column label="序号" align="center" prop="index" width="50"/>
          <el-table-column label="货品类型" prop="type" width="150">
            <template #default="scope">
              <el-select v-model="scope.row.type" placeholder="请选择货品类型" size="mini">
                <el-option v-for="dict in dict.type.ProductType" :key="dict.value" :label="dict.label"
                           :value="parseInt(dict.value)"/>
              </el-select>
            </template>
          </el-table-column>
          <el-table-column label="货品名称" prop="type" width="150">
            <template #default="scope">
              <el-input v-model="scope.row.name" placeholder="请输入货品名称" size="mini"/>
            </template>
          </el-table-column>
          <el-table-column label="包装类型" prop="packageType" width="150">
            <template #default="scope">
              <el-select v-model="scope.row.packageType" placeholder="请选择货品类型" size="mini">
                <el-option v-for="dict in dict.type.Baozhuang" :key="dict.value" :label="dict.label"
                           :value="dict.value + ''"/>
              </el-select>
            </template>
          </el-table-column>
          <el-table-column label="数量" prop="number">
            <template #default="scope">
              <el-input type="number" min="0" v-model="scope.row.number" placeholder="请输入数量" size="mini"
                        @change="changeFee"/>
            </template>
          </el-table-column>
          <el-table-column label="重量" prop="weight">
            <template #default="scope">
              <el-input type="number" min="0" v-model="scope.row.weight" placeholder="请输入重量" size="mini"/>
            </template>
          </el-table-column>
          <el-table-column label="体积" prop="volume">
            <template #default="scope">
              <el-input type="number" min="0" v-model="scope.row.volume" placeholder="请输入体积" size="mini"
                        @change="changeFee"/>
            </template>
          </el-table-column>
          <el-table-column label="计重" prop="jzWeight">
            <template slot-scope="scope">
              <el-input type="number" min="0" v-model="scope.row.jzWeight" size="mini" @change="changeFee"/>
            </template>
          </el-table-column>
          <el-table-column label="货值" prop="value">
            <template slot-scope="scope">
              <el-input type="number" min="0" v-model="scope.row.value" size="mini"/>
            </template>
          </el-table-column>
          <el-table-column label="备注" prop="description">
            <template #default="scope">
              <el-input v-model="scope.row.description" placeholder="请输入备注" size="mini"/>
            </template>
          </el-table-column>
        </el-table>
      </el-row>
      <el-row :gutter="20" style="margin-top: 15px;margin-bottom: 15px;">
        <el-col :span="8">
          <el-form-item label="单价" prop="price">
            <el-input type="number" min="0" v-model="form.price" placeholder="请输入单价"/>
          </el-form-item>
        </el-col>
        <el-col :span="8">
          <el-form-item label="计算方式" prop="jsType">
            <el-radio-group v-model="form.jsType">
              <el-radio v-for="dict in dict.type.JSFS" :key="dict.value" :label="parseInt(dict.value)">{{
                  dict.label
                }}
              </el-radio>
            </el-radio-group>
          </el-form-item>
        </el-col>
      </el-row>

      <div v-hasRole="['financial']">
        <el-divider content-position="left"><span class="divider-text">费用信息</span></el-divider>
        <el-row :gutter="20">
          <el-row :gutter="10" class="mb8">
            <el-col :span="1.5">
              <el-button type="primary" icon="el-icon-plus" size="mini" @click="handleAddJcLedgerDetail">添加
              </el-button>
            </el-col>
            <el-col :span="1.5">
              <el-button type="danger" icon="el-icon-delete" size="mini" @click="handleDeleteJcLedgerDetail">删除
              </el-button>
            </el-col>
          </el-row>
          <el-table :data="jcLedgerDetailList" :row-class-name="rowJcLedgerDetailIndex"
                    @selection-change="handleJcLedgerDetailSelectionChange" ref="jcLedgerDetail" show-summary
                    :summary-method="getLedgerSummaries">
            <el-table-column type="selection" width="60" align="center"/>
            <el-table-column label="序号" align="center" prop="index" width="50"/>
            <el-table-column label="费用名称" prop="name" width="150">
              <template #default="scope">
                <el-select v-model="scope.row.jcFeeTypeId" placeholder="请选择费用名称" size="mini"
                           @change="changeFeeType($event, scope.row)">
                  <el-option v-for="dict in feeTypeData" :key="dict.id" :label="dict.name" :value="dict.id"
                             @change="changeFeeType(dict)"/>
                </el-select>
              </template>
            </el-table-column>
            <el-table-column label="应收金额" prop="amount">
              <template #default="scope">
                <el-input type="number" v-model="scope.row.amount" placeholder="请输入金额" size="mini"
                          @input="changeAmount(scope.row)"/>
              </template>
            </el-table-column>
            <el-table-column label="税率" prop="taxrate">
              <template #default="scope">
                <el-select v-model="scope.row.taxrate" placeholder="请选择税率" size="mini">
                  <el-option v-for="dict in dict.type.TaxRate" :key="dict.value" :label="dict.label"
                             :value="Number(dict.label)"/>
                </el-select>
              </template>
            </el-table-column>
            <el-table-column label="税金" prop="input">
              <template #default="scope">
                <el-input type="number" v-model="scope.row.input" placeholder="请输入税金" size="mini"
                          readonly="readonly"/>
              </template>
            </el-table-column>
            <el-table-column label="收入" prop="income">
              <template #default="scope">
                <el-input type="number" v-model="scope.row.income" placeholder="请输入收入" size="mini"
                          readonly="readonly"/>
              </template>
            </el-table-column>
            <el-table-column label="结算方式" prop="settlementMethod">
              <template #default="scope">
                <el-select v-model="scope.row.settlementMethod" placeholder="请选择结算方式" size="mini">
                  <el-option v-for="dict in dict.type.Clearing" :key="dict.value" :label="dict.label"
                             :value="dict.value"/>
                </el-select>
              </template>
            </el-table-column>
            <el-table-column label="收款方式" prop="collectMethod">
              <template #default="scope">
                <el-select v-model="scope.row.collectMethod" placeholder="请选择收款方式" size="mini">
                  <el-option v-for="dict in dict.type.CollectMethod" :key="dict.value" :label="dict.label"
                             :value="dict.value"/>
                </el-select>
              </template>
            </el-table-column>
            <el-table-column label="备注" prop="description">
              <template #default="scope">
                <el-input v-model="scope.row.description" placeholder="请输入备注" size="mini"/>
              </template>
            </el-table-column>
          </el-table>
        </el-row>
      </div>

      <div class="form-footer">
        <el-button v-if="!form.status || form.status === 1" v-hasPermi="['order:order:add']" type="primary"
                   @click="submitForm">保 存
        </el-button>
        <el-button v-if="!form.status || form.status === 1" v-hasPermi="['order:order:add']" type="primary"
                   @click="submitFormAndPrint">保存并打印
        </el-button>
        <el-button @click="cancel">关 闭</el-button>
      </div>
    </el-form>
    <dialog-index ref="dialogIndex" @change="getMapPosition"></dialog-index>
    <print-single-code ref="printSingleCode"></print-single-code>
    <!--    复核订单-->
    <el-dialog title="复核订单" :visible.sync="openRecheckFlag" width="500px" center>
      <el-form ref="recheckForm" :model="form" :rules="recheckRules" label-width="100px">
        <!--        订单号-->
        <el-form-item label="订单号" prop="code">
          <el-input v-model="form.code" disabled/>
        </el-form-item>
        <el-form-item label="复核人" prop="recheckUserId">
          <el-select v-model="form.recheckUserId" filterable clearable remote
                     reserve-keyword placeholder="请输入关键词" :remote-method="remoteUserMethod" :loading="loading">
            <el-option v-for="item in recheckUserOptions" :key="item.userId"
                       :label="item.dept.deptName + '-'+ item.nickName" :value="item.userId"/>
          </el-select>
        </el-form-item>
        <el-form-item label="复核时间" prop="recheckTime">
          <el-date-picker clearable v-model="form.recheckTime" type="datetime" value-format="yyyy-MM-dd HH:mm:ss"
                          placeholder="请选择复核时间" style="width: 65%;">
          </el-date-picker>
        </el-form-item>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="recheckSingleOrder">确 定</el-button>
        <el-button @click="openRecheckFlag = false">取 消</el-button>
      </div>
    </el-dialog>
  </div>
</template>

<script>
import {addOrder, confirmOrder, getOrder, recheckOrder, updateOrder} from "@/api/order/order";
import {listFeeTypeOption} from "@/api/fee/feeType";
import {zoneStoreroomMap} from "@/api/order/storeroom";
import {searchCustomer} from "@/api/extend/customer";
import {addressListByCustomer} from "@/api/extend/receivingparty";
import {targetOrg} from "@/api/kysys/sysOrganization";
import {getZoneByOrgId} from "@/api/extend/serverZone";

import DialogIndex from '@/components/AMap/dialog_index.vue'
import PrintSingleCode from './component/printSingleCode.vue';
import {listUser} from "@/api/system/user";

export default {
  name: "OrderForm",
  dicts: ['Clearing', 'CustomerType', 'OrderStatus', 'HandoverType', 'TaxRate',
    'ConfirmStatus', 'TransportPro', 'CommIsNot', 'JSFS', 'Clearing', 'CollectMethod',
    'AddressType', 'Baozhuang', 'ProductType', 'TransportMenth'],
  components: {
    DialogIndex,
    PrintSingleCode
  },
  data() {
    return {
      // 对话框是否可见
      open: false,
      // 標題
      title: '',
      // 遮罩层
      loading: true,
      // 表单参数
      form: {
        sender: {},
        receiver: {},
        orderProducts: [],
        ledgerDetails: []
      },
      startZoneList: [],
      targetOrgList: [],
      endZoneList: [],
      addressList: [],
      senderAddressList: [],
      receiverAddressList: [],
      customerList: [],
      addrClickType: '',
      // 表单校验
      rules: {
        customerType: [
          {required: true, message: "客户类型不能为空", trigger: "change"}
        ],
        customerName: [
          {required: true, message: "客户名称不能为空", trigger: "blur"}
        ],
        feeType: [
          {required: true, message: "结算方式不能为空", trigger: "change"}
        ],
        handoverType: [
          {required: true, message: "交付方式不能为空", trigger: "change"}
        ],
        isBack: [
          {required: true, message: "是否回单不能为空", trigger: "blur"}
        ],
        relateBill1: [
          {required: true, message: "发货单号不能为空", trigger: "blur"}
        ],
        time: [
          {required: true, message: "订单日期不能为空", trigger: "blur"}
        ],
        transportPro: [
          {required: true, message: "运输性质不能为空", trigger: "blur"}
        ],
        jcToOrganizationId: [
          {required: true, message: "目的站不能为空", trigger: "blur"}
        ],
        jcZoneStoreroomId: [
          {required: true, message: "入库区域不能为空", trigger: "blur"}
        ],
        jcEndZoneId: [
          {required: true, message: "目的运点不能为空", trigger: "blur"}
        ],
        jcStartZoneId: [
          {required: true, message: "出发运点不能为空", trigger: "blur"}
        ],
        jsType: [
          {required: true, message: "计算方式不能为空", trigger: "change"}
        ],
        price: [
          {required: true, message: "单价不能为空", trigger: "blur"}
        ],
        "sender.name": [
          {required: true, message: "发货单位不能为空", trigger: "blur"}
        ],
        "sender.contactperson": [
          {required: true, message: "发货人不能为空", trigger: "blur"}
        ],
        "sender.address": [
          {required: true, message: "发货地址不能为空", trigger: "change"}
        ],
        "sender.addressType": [
          {required: true, message: "发货地址类型不能为空", trigger: "change"}
        ],
        "sender.iphone": [
          {required: true, message: "发货电话不能为空", trigger: "blur"}
        ],
        "sender.detaileAddress": [
          {required: true, message: "发货详细地址不能为空", trigger: "change"}
        ],
        "receiver.name": [
          {required: true, message: "收货单位不能为空", trigger: "blur"}
        ],
        "receiver.contactperson": [
          {required: true, message: "收货人不能为空", trigger: "blur"}
        ],
        "receiver.address": [
          {required: true, message: "收货地址不能为空", trigger: "change"}
        ],
        "receiver.addressType": [
          {required: true, message: "收货地址类型不能为空", trigger: "change"}
        ],
        "receiver.iphone": [
          {required: true, message: "收货电话不能为空", trigger: "blur"}
        ],
        "receiver.detaileAddress": [
          {required: true, message: "收货详细地址不能为空", trigger: "change"}
        ],
      },
      recheckRules: {
        recheckUserId: [
          {required: true, message: "复核人不能为空", trigger: "blur"}
        ],
        recheckTime: [
          {required: true, message: "复核时间不能为空", trigger: "blur"}
        ]
      },
      // 子表选中数据
      checkedJcOrderProduct: [],
      // 订单货品明细表格数据
      jcOrderProductList: [],
      // 子表选中数据
      checkedJcLedgerDetail: [],
      zvolume: 0.0,
      zweight: 0.0,
      znumber: 0.0,
      jcLedgerDetailList: [],
      feeTypeData: [],
      zoneStoreroomList: [],
      openRecheckFlag: false,
      recheckUserOptions: [],
    }
  },
  watch: {
    // 监听 jsType 和 price, 计算金额
    'form.jsType': function () {
      this.changeFee()
    },
    'form.price': function () {
      this.changeFee()
    },
    'form.jcCustomerId': function () {
      this.handleCustomerAddress()
    },
    'form.jcFromOrganizationId': function () {
      this.handleCustomerAddress()
    },
    'form.jcStartZoneId': function () {
      this.handleCustomerAddress()
    },
    'form.jcToOrganizationId': function () {
      this.handleCustomerAddress()
    },
    'form.jcEndZoneId': function () {
      this.handleCustomerAddress()
    },
    // 监听 jcOrderProductList, 计算总数量、总体积、总重量
    jcOrderProductList: {
      handler: function (newVal, oldVal) {
        this.zvolume = 0.0;
        this.zweight = 0.0;
        this.znumber = 0.0;
        newVal.forEach(item => {
          this.zvolume += item.volume ? parseFloat(item.volume) : 0.0;
          this.zweight += item.weight ? parseFloat(item.weight) : 0.0;
          this.znumber += item.number ? parseFloat(item.number) : 0.0;
        })
        // 并且计算费用
        this.changeFee()
      },
      deep: true
    }
  },
  created() {
    this.reset();
    this.getStartZone()
    this.getTargetOrg()
    this.getFeeTypeData()
    this.getZoneStoreroomData()
    const orderId = this.$route.params && this.$route.params.orderId;
    if (orderId) {
      this.handleUpdate(orderId)
    }
  },
  methods: {
    getStartZone() {
      this.startZoneList = []
      getZoneByOrgId(null).then(response => {
        if (response.data) {
          this.startZoneList = response.data
        }
      })
    },
    getTargetOrg() {
      this.targetOrgList = []
      targetOrg().then(response => {
        if (response.data) {
          this.targetOrgList = response.data
        }
      })
    },
    getEndZone(val) {
      this.endZoneList = []
      if (val) {
        getZoneByOrgId(val).then(response => {
          if (response.data) {
            this.endZoneList = response.data
          }
        })
      }

    },
    getFeeTypeData() {
      this.feeTypeData = []
      listFeeTypeOption('1.1').then(response => {
        if (response.data) {
          this.feeTypeData = response.data
        }
      })
    },
    getZoneStoreroomData() {
      this.zoneStoreroomList = []
      zoneStoreroomMap().then(response => {
        if (response.data) {
          this.zoneStoreroomList = response.data
          // 默认选中第一个
          this.form.jcZoneStoreroomId = response.data[0].id
        }
      })
    },
    // 取消按钮
    cancel() {
      this.open = false;
      this.reset();
      this.$tab.closeOpenPage({path: "/product/order/newOrder"});
    },
    // 表单重置
    reset() {
      this.resetForm("form");
      this.form = {
        id: null,
        code: null,
        description: null,
        name: null,
        status: null,
        recheckStatus: null,
        recheckTime: null,
        recheckUserId: null,
        backNumber: null,
        customerIsExceed: null,
        customerName: null,
        customerType: 1,
        jcCustomerId: null,
        feeType: 0,
        fyTime: null,
        handoverType: 0,
        isAbnormal: null,
        isBack: 0,
        isBilling: 0,
        jsStatus: null,
        number: null,
        orderMileage: null,
        relateBill1: null,
        relateBill2: null,
        relateBill3: null,
        relateBill4: null,
        relateBill5: null,
        salePerson: null,
        shipmentMethod: null,
        isConfirm: null,
        time: new Date(),
        transportPro: 0,
        value: null,
        volume: null,
        weight: null,
        ydTime: null,
        jcOrganizationId: null,
        jcSettlementId: null,
        jcDispatchId: null,
        factArriveTime: null,
        factLeaveTime: null,
        planArriveTime: null,
        planLeaveTime: null,
        jcFromOrganizationId: null,
        jcToOrganizationId: null,
        hxMoney: null,
        hxType: null,
        whxMoney: null,
        jcZoneStoreroomId: null,
        jcEndZoneId: null,
        jcStartZoneId: null,
        isTake: null,
        agent: null,
        qsTime: null,
        qsPerson: null,
        jzWeight: null,
        jcPrescoId: null,
        jsType: null,
        price: 0,
        zAmount: null,
        sender: {
          id: null,
          description: null,
          name: null,
          status: null,
          address: null,
          addressType: 'city',
          contactperson: null,
          factArriveTime: null,
          factLeaveTime: null,
          iphone: null,
          ltl: null,
          orderby: null,
          planLeaveTime: null,
          requireArriveTime: null,
          type: null,
          jcOrderId: null,
          jcZoneId: null,
          detaileAddress: null
        },
        receiver: {
          id: null,
          description: null,
          name: null,
          status: null,
          address: null,
          addressType: 'city',
          contactperson: null,
          factArriveTime: null,
          factLeaveTime: null,
          iphone: null,
          ltl: null,
          orderby: null,
          planLeaveTime: null,
          requireArriveTime: null,
          type: null,
          jcOrderId: null,
          jcZoneId: null,
          detaileAddress: null
        },
        orderProducts: [],
        // 台帐明细表格数据
        ledgerDetails: []
      }
      this.jcOrderProductList = [];
      this.jcLedgerDetailList = [];

    },
    /** 修改按钮操作 */
    handleUpdate(orderId) {
      this.reset();
      getOrder(orderId).then(response => {
        this.form = response.data;
        if (response.data.orderProducts) {
          this.jcOrderProductList = response.data.orderProducts;
        }
        if (response.data.ledgerDetails) {
          this.jcLedgerDetailList = response.data.ledgerDetails;
        }
        if (response.data.sender) {
          this.form.sender = response.data.sender;
        }
        if (response.data.receiver) {
          this.form.receiver = response.data.receiver;
        }
        if (response.data.jcToOrganizationId) {
          this.getEndZone(response.data.jcToOrganizationId)
        }
        this.open = true;
        this.title = "修改订单";
      });
    },
    /** 提交按钮 */
    submitForm() {
      this.$refs["form"].validate(valid => {
        if (valid) {
          this.form.orderProducts = this.jcOrderProductList
          this.form.ledgerDetails = this.jcLedgerDetailList
          if (this.form.id != null) {
            updateOrder(this.form).then(response => {
              this.$modal.msgSuccess("修改成功");
              this.$tab.closeOpenPage({path: "/product/order/newOrder"});
            });
          } else {
            addOrder(this.form).then(response => {
              this.$modal.msgSuccess("新增成功");
              this.$tab.closeOpenPage({path: "/product/order/newOrder"});
            });
          }
        }
      });
    },
    submitFormAndPrint() {
      this.$refs["form"].validate(valid => {
        if (valid) {
          this.form.orderProducts = this.jcOrderProductList
          this.form.ledgerDetails = this.jcLedgerDetailList
          if (this.form.id != null) {
            updateOrder(this.form).then(response => {
              this.$modal.msgSuccess("修改成功");
            });
          } else {
            addOrder(this.form).then(response => {
              this.$modal.msgSuccess("新增成功");
              this.form.id = response.id;
            });
          }
        }
      });
      this.printSingleOrder()
      this.$tab.closeOpenPage({path: "/product/order/newOrder"});
    },
    /** 订单货品明细序号 */
    rowJcOrderProductIndex({row, rowIndex}) {
      row.index = rowIndex + 1;
    },
    /** 订单货品明细添加按钮操作 */
    handleAddJcOrderProduct() {
      let obj = {};
      obj.type = 1;
      obj.description = "";
      obj.name = "";
      obj.status = "";
      obj.number = "";
      obj.packageType = '9';
      obj.unit = "";
      obj.value = "";
      obj.volume = "";
      obj.weight = "";
      obj.jzWeight = "";
      this.jcOrderProductList.push(obj);
    },
    handleAddYP() {
      let obj = {};
      obj.type = 1;
      obj.description = "";
      obj.name = "药品";
      obj.status = "";
      obj.number = "";
      obj.packageType = '9';
      obj.unit = "";
      obj.value = "";
      obj.volume = "";
      obj.weight = "";
      obj.jzWeight = "";
      this.jcOrderProductList.push(obj);
    },
    /** 订单货品明细删除按钮操作 */
    handleDeleteJcOrderProduct() {
      if (this.checkedJcOrderProduct.length === 0) {
        this.$modal.msgError("请先选择要删除的订单货品明细数据");
      } else {
        const jcOrderProductList = this.jcOrderProductList;
        const checkedJcOrderProduct = this.checkedJcOrderProduct;
        this.jcOrderProductList = jcOrderProductList.filter(function (item) {
          return checkedJcOrderProduct.indexOf(item.index) === -1
        });
      }
    },
    /** 复选框选中数据 */
    handleJcOrderProductSelectionChange(selection) {
      this.checkedJcOrderProduct = selection.map(item => item.index)
    },
    /** 台帐明细序号 */
    rowJcLedgerDetailIndex({row, rowIndex}) {
      row.index = rowIndex + 1;
    },
    /** 台帐明细添加按钮操作 */
    handleAddJcLedgerDetail() {
      let obj = {};
      obj.description = "";
      obj.name = "";
      obj.status = "";
      obj.amount = "";
      obj.input = "";
      obj.occurrenceTime = "";
      obj.taxrate = '0.09';
      obj.jcFeeTypeId = 139;
      obj.jcFeeTypeCode = "";
      obj.jcLedgerId = "";
      obj.cost = "";
      obj.type = "";
      obj.jcPrescoId = "";
      obj.jcShipmentId = "";
      obj.jcDispatchId = "";
      obj.jcFeeSeedId = "";
      obj.jcOtherfeeId = "";
      obj.arrivePay = "";
      obj.backPay = "";
      obj.hxmoney = "";
      obj.monthPay = "";
      obj.nowPay = "";
      obj.whmoney = "";
      obj.cashAdvances = "";
      obj.oilPrepaid = "";
      obj.yuE = "";
      obj.zFy = "";
      obj.zGxyf = "";
      obj.zQtfy = "";
      obj.zShf = "";
      obj.zThf = "";
      obj.yajin = "";
      obj.yfYouka = "";
      obj.income = "";
      obj.outcome = "";
      obj.jcShipmentTemplateId = "";
      obj.jcCarrierId = "";
      obj.affirmTime = "";
      obj.isConfirm = "";
      obj.collectMethod = "";
      obj.payMethod = "";
      obj.settlementMethod = "";
      this.jcLedgerDetailList.push(obj);
    },
    /** 台帐明细删除按钮操作 */
    handleDeleteJcLedgerDetail() {
      if (this.checkedJcLedgerDetail.length === 0) {
        this.$modal.msgError("请先选择要删除的台帐明细数据");
      } else {
        const jcLedgerDetailList = this.jcLedgerDetailList;
        const checkedJcLedgerDetail = this.checkedJcLedgerDetail;
        this.jcLedgerDetailList = jcLedgerDetailList.filter(function (item) {
          return checkedJcLedgerDetail.indexOf(item.index) === -1
        });
      }
    },
    /** 复选框选中数据 */
    handleJcLedgerDetailSelectionChange(selection) {
      this.checkedJcLedgerDetail = selection.map(item => item.index)
    },
    changeFee() {
      let input;
      let tax;

      let je = this.jcLedgerDetailList;
      if (!je && je.length === 0) {
        this.handleAddJcLedgerDetail()
        je = this.jcLedgerDetailList;
      }
      let feeTypeIndex; //索引
      const jiesuan = this.form.feeType;
      let panding = false;
      let amount = 0.0;
      for (let i = 0; i < je.length; i++) {//循环取出运费
        const jemx = je[i];
        if (jemx.jcFeeTypeCode === 'YF') {
          feeTypeIndex = i
          panding = true
          break
        }
      }
      if (panding) {
        var jsfs = this.form.jsType;
        if (jsfs === 0) {
          //按重量计费
          amount = (this.zweight * this.form.price).toFixed(3)
          je[feeTypeIndex].amount = amount
          tax = je[feeTypeIndex].taxRate;
          input = amount / (1 + tax) * tax;
          je[feeTypeIndex].input = input.toFixed(3)
          je[feeTypeIndex].income = (amount - input).toFixed(3)
          if (jiesuan === 0) {
            //月结
            je[feeTypeIndex].monthPay = amount
            je[feeTypeIndex].nowPay = 0.00
            je[feeTypeIndex].arrivePay = 0.00
            je[feeTypeIndex].backPay = 0.00
          }
          if (jiesuan === 1) {
            //现结
            je[feeTypeIndex].nowPay = amount
            je[feeTypeIndex].monthPay = 0.00
            je[feeTypeIndex].arrivePay = 0.00
            je[feeTypeIndex].backPay = 0.00
          }
          if (jiesuan === 2) {
            //到付
            je[feeTypeIndex].arrivePay = amount
            je[feeTypeIndex].nowPay = 0.00
            je[feeTypeIndex].monthPay = 0.00
            je[feeTypeIndex].backPay = 0.00
          }
          if (jiesuan === 3) {
            //回付
            je[feeTypeIndex].backPay = amount
            je[feeTypeIndex].arrivePay = 0.00
            je[feeTypeIndex].nowPay = 0.00
            je[feeTypeIndex].monthPay = 0.00
          }
        } else if (jsfs === 1) {
          //按件数计费
          amount = (this.znumber * this.form.price).toFixed(3)
          je[feeTypeIndex].amount = amount
          tax = je[feeTypeIndex].taxRate;
          input = amount / (1 + tax) * tax;
          je[feeTypeIndex].input = input.toFixed(3)
          je[feeTypeIndex].income = (amount - input).toFixed(3)
          if (jiesuan === 0) {
            //月结
            je[feeTypeIndex].monthPay = amount
            je[feeTypeIndex].nowPay = 0.00
            je[feeTypeIndex].arrivePay = 0.00
            je[feeTypeIndex].backPay = 0.00
          }
          if (jiesuan === 1) {
            //现结
            je[feeTypeIndex].nowPay = amount
            je[feeTypeIndex].monthPay = 0.00
            je[feeTypeIndex].arrivePay = 0.00
            je[feeTypeIndex].backPay = 0.00
          }
          if (jiesuan === 2) {
            //到付
            je[feeTypeIndex].arrivePay = amount
            je[feeTypeIndex].nowPay = 0.00
            je[feeTypeIndex].monthPay = 0.00
            je[feeTypeIndex].backPay = 0.00
          }
          if (jiesuan === 3) {
            //回付
            je[feeTypeIndex].backPay = amount
            je[feeTypeIndex].arrivePay = 0.00
            je[feeTypeIndex].nowPay = 0.00
            je[feeTypeIndex].monthPay = 0.00
          }
        } else if (jsfs === 2) {
          //按体积计费
          amount = (this.zvolume * this.form.price).toFixed(3)
          je[feeTypeIndex].amount = amount
          tax = je[feeTypeIndex].taxRate;
          input = amount / (1 + tax) * tax;
          je[feeTypeIndex].input = input.toFixed(3)
          je[feeTypeIndex].income = (amount - input).toFixed(3)
          if (jiesuan === 0) {
            //月结
            je[feeTypeIndex].monthPay = amount
            je[feeTypeIndex].nowPay = 0.00
            je[feeTypeIndex].arrivePay = 0.00
            je[feeTypeIndex].backPay = 0.00
          }
          if (jiesuan === 1) {
            //现结
            je[feeTypeIndex].nowPay = amount
            je[feeTypeIndex].monthPay = 0.00
            je[feeTypeIndex].arrivePay = 0.00
            je[feeTypeIndex].backPay = 0.00
          }
          if (jiesuan === 2) {
            //到付
            je[feeTypeIndex].arrivePay = amount
            je[feeTypeIndex].nowPay = 0.00
            je[feeTypeIndex].monthPay = 0.00
            je[feeTypeIndex].backPay = 0.00
          }
          if (jiesuan === 3) {
            //回付
            je[feeTypeIndex].backPay = amount
            je[feeTypeIndex].arrivePay = 0.00
            je[feeTypeIndex].nowPay = 0.00
            je[feeTypeIndex].monthPay = 0.00
          }
        }
      }
    },
    changeFeeType(item) {
      row.name = item.name
      row.jcFeeTypeCode = item.code
    },
    changeAmount(row) {
      row.input = (row.amount * row.taxrate).toFixed(3)
      row.income = row.amount - row.input
    },
    getProductSummaries(param) {
      const {columns, data} = param;
      const sums = [];
      columns.forEach((column, index) => {
        if (index === 0) {
          sums[index] = '总和';
          return;
        }
        if (index === 1 || index === 2 || index === 3 || index === 4 || index === 10) {
          sums[index] = '';
          return;
        }
        const values = data.map(item => item[column.property]);
        if (!values.every(value => isNaN(value))) {
          sums[index] = values.reduce((prev, curr) => {
            const value = Number(curr);
            if (!isNaN(value)) {
              return Number(prev) + value;
            } else {
              return Number(prev);
            }
          }, 0);
        } else {
          sums[index] = '-';
        }
      });

      return sums;
    },
    getLedgerSummaries(param) {
      const {columns, data} = param;
      const sums = [];
      columns.forEach((column, index) => {
        if (index === 0) {
          sums[index] = '总价';
          return;
        }
        if (index === 1 || index === 2 || index === 4 || index === 7 || index === 8 || index === 9 || index === 10) {
          sums[index] = '';
          return;
        }
        const values = data.map(item => item[column.property]);
        if (!values.every(value => isNaN(value))) {
          sums[index] = values.reduce((prev, curr) => {
            const value = Number(curr);
            if (!isNaN(value)) {
              return (Number(prev) + value).toFixed(3);
            } else {
              return Number(prev).toFixed(3);
            }
          }, 0);
          sums[index] += ' 元';
        } else {
          sums[index] = '-';
        }
      });

      return sums;
    },
    selectPosition(type) {
      this.addrClickType = type
      if (type === 'sender' && this.form.sender.ltl) {
        var ltls = this.form.sender.ltl.split(',')
        this.$refs.dialogIndex.openMap(ltls[0], ltls[1])
      } else if (type === 'receiver' && this.form.receiver.ltl) {
        var ltls = this.form.receiver.ltl.split(',')
        this.$refs.dialogIndex.openMap(ltls[0], ltls[1])
      } else {
        this.$refs.dialogIndex.openMap()
      }
    },
    getMapPosition(data) {
      debugger
      if (this.addrClickType === 'sender') {
        this.form.sender.address = data.address
        this.form.sender.detaileAddress = data.address
        this.form.sender.ltl = data.latitude + ',' + data.longitude
        if (data.addressComponent) {
          this.form.sender.jcZoneId = data.addressComponent.adcode
        }
      } else if (this.addrClickType === 'receiver') {
        this.form.receiver.address = data.address
        this.form.receiver.detaileAddress = data.address
        this.form.receiver.ltl = data.latitude + ',' + data.longitude
        if (data.addressComponent) {
          this.form.receiver.jcZoneId = data.addressComponent.adcode
        }
      }
      this.$forceUpdate();
    },
    queryCustomerSearch(queryString, cb) {
      this.addressList = []
      if (!queryString || queryString.length < 4) {
        cb([]);
        return;
      }
      searchCustomer(queryString).then(response => {
        if (response.data && response.data.length > 0) {
          var list = response.data.map(item => {
            return {
              id: item.id,
              value: item.name
            };
          });
          cb(list);
        }
      });
    },
    remoteCustomerSearch(queryString) {
      this.customerList = []
      if (!queryString || queryString.length < 4) {
        return;
      }
      searchCustomer(queryString).then(response => {
        if (response.data && response.data.length > 0) {
          this.customerList = response.data
        }
      });
    },
    handleCustomer(value) {
      const item = this.customerList.find(item => item.id === value)
      // 获取客户地址信息
      this.form.jcCustomerId = item.id
      this.form.customerName = item.value

    },
    handleCustomerAddress() {
      this.senderAddressList = []
      this.receiverAddressList = []
      // 获取客户地址
      const params = {
        customerId: this.form.jcCustomerId,
        jcFromOrganizationId: this.form.jcFromOrganizationId,
        jcStartZoneId: this.form.jcStartZoneId,
        jcToOrganizationId: this.form.jcToOrganizationId,
        jcEndZoneId: this.form.jcEndZoneId,
      }
      addressListByCustomer(params).then(response => {
        if (response.code === 200) {
          this.senderAddressList = response.senderAddressList
          this.receiverAddressList = response.receiverAddressList
        }
      })
    },
    blurSenderCustomerAddress(e) {
      let value = e.target.value; // 输入框值
      if (value) {
        // 你输入才有这个值 不为空，如果你下拉框选择的话 这个值为空
        this.form.sender.name = value;
      }
      this.$forceUpdate();
    },
    blurReceiverCustomerAddress(e) {
      let value = e.target.value; // 输入框值
      if (value) {
        // 你输入才有这个值 不为空，如果你下拉框选择的话 这个值为空
        this.form.receiver.name = value;
      }
      this.$forceUpdate();
    },
    changeCustomerAddress(item, addrClickType) {
      if (addrClickType === 'sender') {
        this.form.sender.address = item.address
        this.form.sender.detaileAddress = item.detaileAddress
        this.form.sender.contactperson = item.contactperson
        this.form.sender.iphone = item.iphone
        this.form.sender.jcZones = item.jcZones
        this.form.sender.addressType = item.addressType
        this.form.sender.ltl = item.ltl
      } else if (addrClickType === 'receiver') {
        this.form.receiver.address = item.address
        this.form.receiver.detaileAddress = item.detaileAddress
        this.form.receiver.contactperson = item.contactperson
        this.form.receiver.iphone = item.iphone
        this.form.receiver.jcZones = item.jcZones
        this.form.sender.addressType = item.addressType
        this.form.receiver.ltl = item.ltl
      }
      this.$forceUpdate();
    },
    changeToOrg(val) {
      // 获取目的运点
      this.form.jcEndZoneId = null
      this.getEndZone(val)
    },
    changeEndZone(val) {
      // 获取入库区域
      this.$forceUpdate()
    },
    openRecheck() {
      this.openRecheckFlag = true;
      this.resetForm("recheckForm");
    },
    remoteUserMethod(query) {
      if (query !== '' && query.length >= 1) {
        this.loading = true;
        this.recheckUserOptions = [];
        const params = {
          nickName: query,
          pageSize: 10,
          pageNum: 1
        }
        listUser(params).then(response => {
          this.recheckUserOptions = response.rows
          this.loading = false
        })
      } else {
        this.recheckUserOptions = [];
      }
    },
    recheckSingleOrder() {
      const recheckData = {
        ids: [this.form.id],
        recheckUserId: this.form.recheckUserId,
        recheckTime: this.form.recheckTime
      }
      recheckOrder(recheckData).then(response => {
        this.getList();
        this.openRecheckFlag = false;
        this.$modal.msgSuccess("确认成功！");
      });
    },
    confirmSingleOrder() {
      this.$confirm('是否确认单据？', '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning'
      }).then(() => {
        confirmOrder(this.form.id).then(response => {
          this.form.status = 2;
          this.$modal.msgSuccess("确认成功！");
        });
      }).catch(() => {
      });
    },
    printSingleOrder() {
      this.$refs.printSingleCode.openDialog(this.form.id)
    },
  }
};
</script>
<style scoped>
.el-date-editor.el-input,
.el-date-editor.el-input__inner {
  width: 175px;
}

.el-form-item {
  margin-bottom: 15px;
}

.order-form-page {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.order-form__header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px clamp(16px, 2vw, 24px);
  margin-bottom: 12px;
  border-radius: 12px;
  border: 1px solid rgba(226, 232, 240, 0.9);
  background-color: #f8fafc;
}

.order-form__title {
  font-size: 18px;
  font-weight: 600;
  color: #1f2937;
}

.order-form__actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}

.order-form__actions .el-button {
  margin-right: 0;
}

.form-footer {
  text-align: center;
  margin-top: 20px;
}

.divider-text {
  font-weight: bold;
  font-size: 18px;
  color: #409EFF;
}
</style>
